#!/usr/bin/env python3
# coding: utf-8
# Copyright (c) 2025 Huawei Technologies Co., Ltd.
# This file is a part of the CANN Open Software.
# Licensed under CANN Open Software License Agreement Version 1.0 (the "License").
# Please refer to the License for details. You may not use this file except in compliance with the License.
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
# See LICENSE in the root of the software repository for the full text of the License.
# ======================================================================================================================
api: pytorch
api_type: function_aclnn_grouped_matmul_V4_a8w4
aclnn_api_type: function_pyaclnn_grouped_matmul_V4_a8w4
version: v2.1
name: grouped.matmul
aclnn_name: GroupedMatmulV4
generate: ascend_generate_grouped_matmul_V4_a8w4
dtype_numbers : 20
extra_numbers: 0
# tuple_numbers : 2
standard:
    acc: 
        cv_fused_double_benchmark
inputs:
  - name: x  #第0个
    type: tensors
    required: true
    tuple_numbers:
        values: [ 1 ]
    dtypes:
        values: [int8]
    shapes:
        dim_numbers:
            values: [2]
        dim_values:
            values: [1, 7, 8, 9, 15, 16, 17, 19, 20, 21, 255, 256, 257, 13107, [1, 1024]]
    ranges:
        valid:
            values: [[-5, 5]]
            # random_types:
            #     - name: nd
        invalid:
            values: [[-inf], [inf], [nan]]

  - name: weight  #第1个
    type: tensors
    required: true
    tuple_numbers:
        values: [ 1 ]
    dtypes:
        values: [int32]
    shapes:
        dim_numbers:
            values: [3]
        dim_values:
            values: [1, 2,3,4,5,6,7, 8, 9, 15, 16, 17, 19, 20, 21, 255, 256, [1, 32]]
    ranges:
        valid:
            values: [[-5, 5]]
            # random_types:
            #     - name: nd
        invalid:
            values: [[-5, 5]]

  - name: biasOptional  #第2个
    type: tensors
    required: true
    tuple_numbers:
        values: [ 1 ]
    dtypes:
        values: [fp32]
    shapes:
        dim_numbers:
            values: [2]
        dim_values:
            values: [1]
    ranges:
        valid:
            values: [[-5, 5]]
            # random_types:
            #     - name: nd
        invalid:
            values: [[-inf], [inf], [nan]]

  - name: scaleOptional # 第3个 
    type: tensors
    required: true
    tuple_numbers:
        values: [ 1 ]
    dtypes:
        values: [fp32]
    shapes:
        dim_numbers:
            values: [3]
        dim_values:
            values: [1]
    ranges:
        valid:
            values: [[0,1]]
            # random_types:
            #     - name: nd
            #       mean: [0,1]
            #       std: [0,1]
        invalid:
            values: [[0,1]]

  - name: offsetOptional # 不支持参数, 不进行泛化  #第4个
    type: tensors
    required: true
    tuple_numbers:
        values: [ 1 ]
    dtypes:
        values: [bf16]
    shapes:
        dim_numbers:
            values: [1]
        dim_values:
            values: [1]
    ranges:
        valid:
            values: [0]
        invalid:
            values: [0]

  - name: antiquantScaleOptional # 不支持参数, 不进行泛化  #第5个
    type: tensors
    required: true
    tuple_numbers:
        values: [ 1 ]
    dtypes:
        values: [bf16]
    shapes:
        dim_numbers:
            values: [1]
        dim_values:
            values: [1]
    ranges:
        valid:
            values: [0]
        invalid:
            values: [0]

  - name: antiquantOffsetOptional # 不支持参数, 不进行泛化  #第6个
    type: tensors
    required: true
    tuple_numbers:
        values: [ 1 ]
    dtypes:
        values: [bf16]
    shapes:
        dim_numbers:
            values: [1]
        dim_values:
            values: [1]
    ranges:
        valid:
            values: [0]
        invalid:
            values: [0]

  - name: perTokenScaleOptional   #第7个
    type: tensors
    required: true
    tuple_numbers:
        values: [ 1 ]
    dtypes:
        values: [fp32]
    shapes:
        dim_numbers:
            values: [2]
        dim_values:
            values: [1]
    ranges:
        valid:
            values: [[0,1]]
        invalid:
            values: [[0,1]]

  - name: groupListOptional    #第8个
    type: tensor
    required: true
    dtypes:
        values: [int64]
    shapes:
        dim_numbers:
            values: [1]
        dim_values:
            values: [1]
    ranges:
        valid:
            values: [1]
            # random_types:
            #     - name: nd
        invalid:
            values: [1]

  - name: activationInputOptional # 不支持参数, 不进行泛化，传入空指针  #第9个
    type: tensors
    required: true
    tuple_numbers:
        values: [ 1 ]
    dtypes:
        values: [bf16]
    shapes:
        dim_numbers:
            values: [1]
        dim_values:
            values: [1]
    ranges:
        valid:
            values: [0]
        invalid:
            values: [0]

  - name: activationQuantScaleOptional # 不支持参数, 不进行泛化，传入空指针  #第10个
    type: tensors
    required: true
    tuple_numbers:
        values: [ 1 ]
    dtypes:
        values: [bf16]
    shapes:
        dim_numbers:
            values: [1]
        dim_values:
            values: [1]
    ranges:
        valid:
            values: [0]
        invalid:
            values: [0]

  - name: activationQuantOffsetOptional # 不支持参数, 不进行泛化，传入空指针  #第11个
    type: tensors
    required: true
    tuple_numbers:
        values: [ 1 ]
    dtypes:
        values: [bf16]
    shapes:
        dim_numbers:
            values: [1]
        dim_values:
            values: [1]
    ranges:
        valid:
            values: [0]
        invalid:
            values: [0]

  - name: splitItem # 确定输出是多tensor还是单tensor  #第12个
    type: attr
    dtypes:
        values: [ int ]
    ranges:
        valid:
            values: [3]
        invalid:
            values: [3]

  - name: groupType # 计算前的切分方式，groupType取值-1：不分组，0：m轴分组，1：n轴分组，2：k轴分组  #第13个
    type: attr
    dtypes:
        values: [ int ]
    ranges:
        valid:
            values: [0]
        invalid:
            values: [0]

  - name: groupListType # gtroupList中数值的意思，0是累加的，1是代表每组大小，当前场景不需要  #第14个
    type: attr
    dtypes:
        values: [ int ]
    ranges:
        valid:
            values: [1]
        invalid:
            values: [1]

  - name: actType # 激活函数，当前支持0  #第15个
    type: attr
    dtypes:
        values: [ int ]
    ranges:
        valid:
            values: [0]
        invalid:
            values: [0]
